﻿using Architecture.API.Application.Command.RequestForLeaveCommand;
using Architecture.Domain;
using Architecture.Domain.Service.LeaveServices;
using MediatR;

namespace Architecture.API.Application.CommandHandlers.RequestForLeaveHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class LeaveReverseCommandHandler : IRequestHandler<LeaveReverseCommand, RequestForLeave>
    {
        /// <summary>
        /// 请假服务
        /// </summary>
        protected readonly ILeaveService _leaveService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="leaveService">请假服务</param>
        public LeaveReverseCommandHandler(ILeaveService leaveService)
        {
            _leaveService = leaveService;
        }

        /// <summary>
        /// 反填请假信息
        /// </summary>
        /// <param name="request">请假申请</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>反填部门信息</returns>
        public async Task<RequestForLeave> Handle(LeaveReverseCommand request, CancellationToken cancellationToken)
        {
            return await _leaveService.ReverseLeave(request.leaveId);
        }
    }
}
